package com.xzq.erp.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

@Getter
public enum Priority implements BaseEnum {
    NORMAL(1, "普通"),
    URGENT(2, "紧急");

    @JsonValue // 指定返回前端为枚举类的value值
    @EnumValue // 指定保存到数据库为枚举类的value值
    int value;
    String desc;

    Priority(int value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
    public static Priority of(Integer value){
        if (value == null) {
            return null;
        }
        for (Priority priority : values()) {
            if (priority.equalsValue(value)) {
                return priority;
            }
        }
        return null;
    }
}
